import React, { useContext } from 'react';
import { AuthContext } from '../../contexts'

export const Header = () => {
  const { state, dispatch }  = useContext(AuthContext)
  // console.log(state, dispatch, '+++++++');
  return (
    <>
      Header
      {state.isAuthenticated ? (
        <div>登录了{state.user.name}:{state.token.t}
          <button onClick={() => { dispatch({ type: 'LOGOUT' })}}>退出登录</button>
        </div>
      ) : (
        <div>未登录</div>
      )}
    </>
  )
}